<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Admin_login extends CI_Controller {

	
	public function index()
	{

		 $this->load->view('backend/v_login');
	}
	
	function do_login()
		{
			$user=$this->input->post('username');
			$pass=sha1($this->input->post('password'));
			
			
			if(empty($user) || empty($pass))
			{
					$this->session->set_flashdata('action_msg','Isikan username dan password');
					
					redirect(base_url().'admin_login');				
			}
			else
			{
					$check_login=$this->site_sentry->login_routine($user,$pass);
					if($check_login==1)
					{
						
						if($this->session->userdata('role_name')==$this->config->item('admin'))
                          {
								redirect(base_url().'admin');
                           }
                           elseif($this->session->userdata('role_name')==$this->config->item('staff'))
                           {
                           		redirect(base_url().'staff');
                           }
                            else
                            {
                            $this->session->set_flashdata('action_msg','Anda bukan pengguna yang berwenang');
							redirect(base_url().'admin_login');
                            }
					}
					else
					{
						$flag=1;
						$this->session->set_flashdata('action_msg','username atau password salah');
						redirect(base_url().'admin_login');
						
					}
			}
		}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */